函数fun的功能是进行字母转换。若形参ch中是小写英文字母,则转换成对应的大写英文字母;若ch中是大写英文字母,则转换成对应的小写英文字母;若是其它字符则保持不变;并将转换后的结果作为函数值返回。
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
注意:源程序存放在考生文件夹下的BLANK1.C中。
不得增行或删行,也不得更改程序的结构!
给定源程序:
#include
#include
char fun(char ch)
{
if ((ch>=’a’)___1___(ch<=’z’))
return ch -’a’ + ’A’;
if ( isupper(ch) )
return ch +’a’-___2___ ;
return ___3___;
}
main()
{ char c1, c2;
printf("\nThe result :\n");
c1=’w’; c2 = fun(c1);
printf("c1=%c c2=%c\n", c1, c2);
c1=’W’; c2 = fun(c1);
printf("c1=%c c2=%c\n", c1, c2);
c1=’8’; c2 = fun(c1);
printf("c1=%c c2=%c\n", c1, c2);
}